// https://www.acwing.com/problem/content/145/

#include <iostream>
#include <vector>

using namespace std;

const int MAX_ARRAY_SIZE = 1e5+5;

int nodes[MAX_ARRAY_SIZE * 31][2];
int idx = 0;

void Insert(int x) {
    int p = 0;
    for (int i=31; i>=0; i--) {
        int t = x >> i & 1;
        if (!nodes[p][t]) {
            nodes[p][t] = ++idx;
        }
        p = nodes[p][t];
    }
}

int Query(int x) {
    int p = 0;
    int res = 0;
    for (int i=31; i>=0; i--) {
        int t = x >> i & 1;
        if (nodes[p][!t]) {
            res = (res << 1) + !t;
            p = nodes[p][!t];
        } else {
            res = (res << 1) + t;
            p = nodes[p][t];
        }
    }
    return res ^ x;
}


int main() {
    int n, x;
    int result = 0;
    cin>>n;
    while (n-->0) {
        cin>>x;
        Insert(x);
        result = max(result, Query(x));
    }
    cout<<result<<endl;
    return 0;
}
